<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.prime.com.tr/ui" >

    <ui:composition  template="/template.xhtml">

        <ui:define name="content">
            <c:choose>
                <c:when test="#{loginController.authenticatedUser==null}">
                    <h:form id="loginformid">
                        <fieldset>
                            <legend>Please provide your login data</legend>
                            <table>
                                <tr>
                                    <td><h:outputLabel for="name" value="User: " /></td>
                                    <td><p:inputText id="name"  value="#{loginController.name}" maxlength="30"/></td>
                                </tr>
                                <tr>
                                    <td>Password:</td>
                                    <td><p:password  feedback="false" minLength="1" value="#{loginController.password}" maxlength="100"/></td>
                                </tr>
                                <tr>
                                    <td>
                                        <p:commandButton  value="Login" ajax="false" actionListener="#{loginController.login}" />
                                    </td>
                                    <td>
                                        <h:link value="Register" outcome="register" />
                                    </td>

                                    <td><p:messages  /></td>
                                </tr>
                            </table>
                        </fieldset>


                    </h:form>
                </c:when>
                <c:otherwise>
                    user: #{loginController.authenticatedUser.loginId} already logged in
                </c:otherwise>
            </c:choose>

        </ui:define>
    </ui:composition>
</html>
